<template>
	<view class="EvaluationCom">
		<view class="user_info_box">
			<view class="l_box">
				<image :src="itemData.image" class="user_img" mode=""></image>
				<view class="user_info">
					<view class="user_name">{{ itemData.real_name }}</view>
					<view class="rate_box">
						<view class="rate_com"><Rate :size="20" :gutter="2" :value="itemData.star" :readonly="true" /></view>
					</view>
				</view>
			</view>
			<view class="r_box">
				<view class="fn-sz-24 fn-cl-9E9E9E mar-bottom-6">{{ itemData.comment_time }}</view>
				<view @tap="handleDel" class="del_btn" v-if="canDel"><button>删除</button></view>
			</view>
		</view>
		<view class="rate_content_box">
			<view class="content_txt">{{ itemData.content }}</view>
			<scroll-view scroll-x scroll-with-animation class="img_scroll_box">
				<view class="img_list">
					<view class="img_itme" @click="previewImage" v-for="(item, index) in itemData.images" :key="index"><image :src="item" mode=""></image></view>
				</view>
			</scroll-view>
		</view>
		<view class="store_return" v-if="itemData.replay">
			<view class="return_txt">
				<text class="fn-sz-28 fn-cl-999999 mar-right-10">商家回复:</text>
				<text class="fn-sz-28 fn-cl-666666">{{ itemData.replay }}</text>
			</view>
		</view>
	</view>
</template>

<script>
import Rate from '../rate/rate.vue';
export default {
	name: 'EvaluationCom',
	components: {
		Rate
	},
	props: {
		itemData: {
			type: Object,
			default: () => ({})
		},
		canDel: {
			type: Boolean,
			defalut: false
		}
	},
	data() {
		return {};
	},
	methods: {
		previewImage() {
			uni.previewImage({
				urls: this.itemData.images
			});
			console.log(this.itemData, 'gwagwa', this.itemData.image);
		},
		handleDel() {
			this.$api
				.deleteComment({
					id: this.itemData.id
				})
				.then(res => {
					this.$helper.mToast('删除成功', _ => {
						this.$mRoute.to('order');
					});
				});
		}
	}
};
</script>

<style lang="scss">
.EvaluationCom {
	.user_info_box {
		display: flex;
		justify-content: space-between;
		align-items: center;
		.l_box {
			display: flex;

			.user_img {
				width: 70rpx;
				height: 70rpx;
				border-radius: 50%;
				overflow: hidden;
			}

			.user_info {
				padding-left: 20rpx;
				padding-top: 4rpx;
				.user_name {
					font-size: 26rpx;
					margin-bottom: 6rpx;
				}

				.rate_box {
					display: flex;
					align-items: center;

					.rate_num {
						font-size: 22rpx;
						color: #ff622d;
						margin-right: 6rpx;
					}

					.rate_com {
						height: 20rpx;
					}
				}
			}
		}

		.r_box {
			.del_btn {
				width: 80rpx;
				float: right;

				button {
					width: 80rpx;
					height: 44rpx;
					font-size: 24rpx;
					color: #999999;
					border-radius: 45rpx 45rpx 45rpx 45rpx;
					background-color: #fff;
					border: 1rpx solid #999999;
					padding: 0 10rpx;
					line-height: 44rpx;
				}
			}
		}
	}

	.rate_content_box {
		padding-top: 32rpx;
		padding-left: 90rpx;
		.content_txt {
			font-size: 24rpx;
			margin-bottom: 31rpx;

			line-height: 46rpx;
		}
		.img_scroll_box {
			position: relative;
			width: 100%;
			height: 160rpx;
			overflow: hidden;
			box-sizing: border-box;
			margin-bottom: 17rpx;
		}
		.img_list {
			display: flex;
			align-items: center;

			.img_itme {
				image {
					width: 160rpx;
					height: 160rpx;
					margin-bottom: 6rpx;
					margin-right: 10rpx;
					overflow: hidden;
					border-radius: 10rpx 10rpx 10rpx 10rpx;
				}
			}
		}
	}

	.store_return {
		padding: 14rpx 19rpx;
		border-radius: 5rpx 5rpx 5rpx 5rpx;
		margin-left: 90rpx;
		background: #f6f6f6;
		border-radius: 5px;
		.return_txt {
			margin-bottom: 20rpx;
			line-height: 46rpx;
		}
		.return_time {
		}
	}
}
</style>
